/**
 * 
 */
package edu.pku.sei.modeler.ocl;

import org.eclipse.emf.ecore.EClass;

import edu.pku.sei.modeler.model.core.EMetaModelPackage;
import edu.pku.sei.modeler.model.core.MetaElement;

/**
 * @author zhubin
 *
 */
public class MetaModelOCLEngine {

	public static MetaModelOCLEngine INSTANCE = init();
	
	private EClass context;
	
	private MetaElement model;
	
	private String queryString;
	
	private static MetaModelOCLEngine init() {
		MetaModelOCLEngine instance = new MetaModelOCLEngine();
		instance.context = null;
		instance.model = null;
		instance.queryString = "";
		return instance;
	}
	
	public void setContext(String contextString){
		context = EMetaModelPackage.Literals.EMETA_CLASS;
	}
	
	public void setModel(MetaElement model){
		this.model = model;
		context = model.eClass();
	}
	
	public void setQuery(String qs){
		queryString = new String(qs);
	}
	
	public String evaluate(){
		if(context == null || model == null || queryString == null || queryString.equals(""))
			return "";
//		OCL ocl = OCL.newInstance();
//        OCLHelper helper = ocl.createOCLHelper();
//        helper.setContext(context);
//        OCLExpression parsed = null;
//		try {
//			parsed = (OCLExpression) helper.createQuery(queryString);
//		} catch (ParserException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//        // evaluate the query
//        Query query = ocl.createQuery(parsed);
//        String result = query.evaluate(model).toString();
		return "";
	}
}
